package compte;

public class Stat {
	protected int year ;
	protected String statType ;
	protected String rowName ;
	protected Q jan ;
	protected Q feb ;
	protected Q mar ;
	protected Q apr ;
	protected Q mai ;
	protected Q jui ;
	protected Q juil ;
	protected Q aug ;
	protected Q sept ;
	protected Q oct ;
	protected Q nov ;
	protected Q dec ;
	protected Q sum ;
	public Stat(String theStatType, String theRowName, int theYear ){
		try {
			statType = theStatType;
			rowName  = theRowName ;
			year = theYear ;
			jan  = new Q(0L,100L) ;
			feb  = new Q(0L,100L) ;
			mar  = new Q(0L,100L) ;
			apr  = new Q(0L,100L) ;
			mai  = new Q(0L,100L) ;
			jui  = new Q(0L,100L) ;
			juil = new Q(0L,100L) ;
			aug  = new Q(0L,100L) ;
			sept = new Q(0L,100L) ;
			oct  = new Q(0L,100L) ;
			nov  = new Q(0L,100L) ;
			dec  = new Q(0L,100L) ;
			sum  = new Q(0L,100L) ;

		} catch (Exception e) {
			System.out.println("New Stat : "+ e.toString());
		}
	}

	public void Add(int theMonth, Q theAmount){
		try {
			if (theMonth <=0 ) return;
			if (theMonth > 12 ) return;
			if (theMonth == 1 ) jan = jan.add(theAmount);
			if (theMonth == 2 ) feb = feb.add(theAmount);
			if (theMonth == 3 ) mar = mar.add(theAmount);
			if (theMonth == 4 ) apr = apr.add(theAmount);
			if (theMonth == 5 ) mai = mai.add(theAmount);
			if (theMonth == 6 ) jui = jui.add(theAmount);
			if (theMonth == 7 ) juil = juil.add(theAmount);
			if (theMonth == 8 ) aug = aug.add(theAmount);
			if (theMonth == 9 ) sept = sept.add(theAmount);
			if (theMonth == 10 ) oct = oct.add(theAmount);
			if (theMonth == 11 ) nov = nov.add(theAmount);
			if (theMonth == 12 ) dec = dec.add(theAmount);
			sum = sum.add(theAmount);

		} catch (Exception e) {
			System.out.println("Stat Add : "+ e.toString());
		}

		return ;
	}
	public boolean Exists(String theStatType, String theRowName, int theYear) {
		return (statType == theStatType && rowName==theRowName && year == theYear );
	}

	void AddInTheDom (Dom theDom){
		theDom.Add16Elts(  "Stat",
				"year", new Integer(year).toString(),
				"statType", statType,
				"rowName", rowName,
				"jan",jan.getEntValue(),
				"feb",feb.getEntValue(),
				"mar",mar.getEntValue(),
				"apr",apr.getEntValue(),
				"mai",mai.getEntValue(),
				"jui",jui.getEntValue(),
				"juil",juil.getEntValue(),
				"aug",aug.getEntValue(),
				"sept",sept.getEntValue(),
				"oct",oct.getEntValue(),
				"nov",nov.getEntValue(),
				"dec",dec.getEntValue(),
				"sum",sum.getEntValue() ) ;
	}  
}
